package com.example.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.backend.entity.ProductListing;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ProductListingMapper extends BaseMapper<ProductListing> {
    
    /**
     * 查询已上架的商品列表
     * @return 商品列表
     */
    @Select("SELECT listing_id, product_name, product_images, product_description, unit_price, seller_id " +
            "FROM product_listing " +
            "WHERE listing_status = 1 " +
            "ORDER BY listing_id DESC")
    List<Map<String, Object>> selectAvailableProducts();
}